
#ifndef _CHARDEV_H_
#define _CHARDEV_H_

#include <types.h>
#include <fd_types.h>
/**
 * The fundamental callbacks for a character device: they are common
 * to all the character devices of the same class. One is free to do
 * whatever she likes with the "custom_data" of the opened file passed
 * as argument
 */
struct chardev_ops {

  int (*open)( open_file_descriptor * of,
		    void * chardev_class_custom_data);

  /**
   * Called each time an opened "character device" is declared unused
   * by user space
   * @note Optional (might be NULL)
   */
  int (*close)(open_file_descriptor * of,
		     void * chardev_class_custom_data);


  /**
   * @note Optional (might be NULL), may block. Appropriate locking
   * MUST be implemented
   */
  int (*read)(open_file_descriptor *this,
		    __u32 dest_buf,
		    __u32 * /* in/out */len);

  /**
   * @note Optional (might be NULL), may block. Appropriate locking
   * MUST be implemented
   *
   */
  int (*write)(open_file_descriptor *this,
		     __u32 src_buf,
		     __u32 *len);

  int (*ioctl)(open_file_descriptor *this,
		     int req_id,
		     __u32 req_arg );

};


#endif 

